<%@ Page Language="C#" MasterPageFile="~/MasterPageMcSigAdmin.master" AutoEventWireup="true"
    CodeFile="PermisosComisiones.aspx.cs" Inherits="PermisosComisiones" Title="Untitled Page" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView.Export" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:SqlDataSource ID="SqlDataSourcePermisosEpes" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT     ADM_PERMISOS_COMISIONES.APC_ID, COM_ESTADOS.COE_ID, COM_ESTADOS.COE_NOMBRE, ADM_USUARIOS.USU_ID, ADM_USUARIOS.USU_NOMBRE,  SIG_PLAN_ACCION.PLN_ID, SIG_PLAN_ACCION.PLN_NOMBRE, SIG_PLAN_ACCION.PLN_ANO, ADM_USUARIOS.USU_ESTADO FROM         ADM_USUARIOS INNER JOIN ADM_PERMISOS_COMISIONES ON ADM_USUARIOS.USU_ID = ADM_PERMISOS_COMISIONES.USU_ID INNER JOIN COM_ESTADOS ON ADM_PERMISOS_COMISIONES.COE_ID = COM_ESTADOS.COE_ID LEFT OUTER JOIN SIG_PLAN_ACCION ON ADM_PERMISOS_COMISIONES.PLN_ID = SIG_PLAN_ACCION.PLN_ID"
        DeleteCommand="DELETE FROM [ADM_PERMISOS_COMISIONES] WHERE [APC_ID] = @APC_ID" 
        InsertCommand="INSERT INTO dbo.ADM_PERMISOS_COMISIONES ( USU_ID, COE_ID, PLN_ID )VALUES  (@USU_ID ,@COE_ID,@PLN_ID)"
        UpdateCommand="UPDATE ADM_PERMISOS_COMISIONES SET USU_ID = @USU_ID, TEP_ID = @COE_ID, PLN_ID = @PLN_ID WHERE [APC_ID] = @APC_ID ">
        <DeleteParameters>
            <asp:Parameter Name="APC_ID" Type="Decimal" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="USU_ID" Type="Decimal" />
            <asp:Parameter Name="COE_ID" Type="Decimal" />
            <asp:Parameter Name="PLN_ID" Type="Decimal" />
            <asp:Parameter Name="APC_ID" Type="Decimal" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="USU_ID" Type="Decimal" />
            <asp:Parameter Name="COE_ID" Type="Decimal" />
            <asp:Parameter Name="PLN_ID" Type="Decimal" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceRubros" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT [PLN_ID], PLN_NOMBRE    AS PLN_NOMBRE  FROM [SIG_PLAN_ACCION] WHERE PLN_ANO = 2015">
    </asp:SqlDataSource>
    <br />
    <asp:SqlDataSource ID="SqlDataSourceUsuarios" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT [USU_ID], [USU_NOMBRE] FROM [ADM_USUARIOS]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceTipoPermisos" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT [COE_ID], [COE_NOMBRE] FROM [COM_ESTADOS]"></asp:SqlDataSource>
    &nbsp;<dx:aspxgridviewexporter id="gridExport" runat="server" gridviewid="ASPxGridView1"> </dx:aspxgridviewexporter>
    <dx:ASPxGridView ID="ASPxGridView1" runat="server" CssFilePath="~/App_Themes/PlasticBlue/{0}/styles.css"
        CssPostfix="PlasticBlue" AutoGenerateColumns="False" DataSourceID="SqlDataSourcePermisosEpes"
        KeyFieldName="APC_ID" Theme="PlasticBlue">
        <Styles CssPostfix="PlasticBlue" CssFilePath="~/App_Themes/PlasticBlue/{0}/styles.css">
            <Header SortingImageSpacing="10px" ImageSpacing="10px">
            </Header>
        </Styles>
        <SettingsPager ShowDefaultImages="False">
            <AllButton Text="All">
            </AllButton>
            <NextPageButton Text="Next &gt;">
            </NextPageButton>
            <PrevPageButton Text="&lt; Prev">
            </PrevPageButton>
        </SettingsPager>
      
        <StylesEditors>
            <CalendarHeader Spacing="11px">
            </CalendarHeader>
            <ProgressBar Height="25px">
            </ProgressBar>
        </StylesEditors>
        <Columns>
            <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                <EditButton Visible="True">
                </EditButton>
                <NewButton Visible="True">
                </NewButton>
                <DeleteButton Visible="True">
                </DeleteButton>
                <ClearFilterButton Visible="True">
                </ClearFilterButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="APC_ID" ReadOnly="True" VisibleIndex="1">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="COE_NOMBRE" VisibleIndex="2">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Estado" FieldName="COE_ID" VisibleIndex="1"
                Visible="False" Width="300px">
                <EditFormSettings Visible="True" />
                <PropertiesComboBox CallbackPageSize="15" TextField="COE_NOMBRE" ValueField="COE_ID"
                    DataSourceID="SqlDataSourceTipoPermisos" EnableCallbackMode="True" EnableIncrementalFiltering="True"
                    ValueType="System.String">
                </PropertiesComboBox>
                <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" ShowFilterRowMenu="True" />
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="USU_NOMBRE" VisibleIndex="3">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Usuario" FieldName="USU_ID" VisibleIndex="1"
                Width="300px">
                <EditFormSettings Visible="True" />
                <PropertiesComboBox CallbackPageSize="15" TextField="USU_NOMBRE" ValueField="USU_ID"
                    DataSourceID="SqlDataSourceUsuarios" EnableCallbackMode="True" EnableIncrementalFiltering="True"
                    ValueType="System.String">
                </PropertiesComboBox>
                <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" ShowFilterRowMenu="True" />
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="PLN_NOMBRE" Caption="PLN_NOMBRE" ReadOnly="True"
                VisibleIndex="4" Width="300px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Rubro" FieldName="PLN_ID" VisibleIndex="1"
                Visible="False" Width="300px">
                <EditFormSettings Visible="True" />
                <PropertiesComboBox CallbackPageSize="15" TextField="PLN_NOMBRE" ValueField="PLN_ID"
                    DataSourceID="SqlDataSourceRubros" EnableCallbackMode="True" EnableIncrementalFiltering="True"
                    ValueType="System.String">
                </PropertiesComboBox>
                <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" ShowFilterRowMenu="True" />
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="PLN_ANO" VisibleIndex="6">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="USU_ESTADO" VisibleIndex="5">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
        </Columns>
        <Settings ShowFilterRow="True" ShowGroupPanel="True" ShowFilterRowMenu="True" />
    </dx:ASPxGridView>
    <asp:Button ID="btnXlsExport" runat="server" CssClass="button m tp-space10" OnClick="btnXlsExport_Click"
        Text="Exportar a XLS" />
</asp:Content>
